/****************************************************************
 ** Product  :   HP Subscriber Network Application Policy
 ** Module   :   gr-manager
 ** Date: Apr 10, 2015               
 ** Author: Joey Yi
 ** (C) Copyright 2015, Hewlett-Packard Company, All Rights Reserved.
 ** This software is the proprietary information of HP, Inc.  
 ** Use is subject to license terms.
 *****************************************************************
 ** Description:   
 **    Constants class 
 **  
 ****************************************************************/
package com.hp.snap.gr.utils;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;

/**
 * Constants class. 
 *
 * <P>
 * Version: 3.3 <br>
 * Author: Joey Yi
 * Date: Apr 10, 2015
 * 
 * </P>
 *
 **/
public class Constants {
    public static final String USER_HOME = System.getProperty("user.home");
    public static String USER_DIR = System.getProperty("user.dir");
    public static String USER_GR_TEMP = USER_DIR + File.separator + "temp";
    public static String USER_GR_WORK = USER_DIR + File.separator + "work";
    public static String USER_GR_CONF = USER_DIR + File.separator + "conf";
    public static String USER_GR_BIN = USER_DIR + File.separator + "bin";
    public static String USER_GR_ARTIFACT = USER_DIR + File.separator + "artifacts";

    static {
        if (StringUtils.isNotEmpty(System.getProperty("GRHome"))) {
            USER_DIR = System.getProperty("GRHome");
        } else {
            String suffix = File.separator + "bin";
            if (USER_DIR.endsWith(suffix)) {
                int index = USER_DIR.lastIndexOf(suffix);
                USER_DIR = USER_DIR.substring(0, index);
            }
        }
        USER_GR_TEMP = USER_DIR + File.separator + "temp";
        USER_GR_WORK = USER_DIR + File.separator + "work";
        USER_GR_CONF = USER_DIR + File.separator + "conf";
        USER_GR_BIN = USER_DIR + File.separator + "bin";
        USER_GR_ARTIFACT = USER_DIR + File.separator + "artifacts";
    }

    // Others
    public static final String SSH_PATH = USER_HOME + File.separator + ".ssh";

    // Action context keys
    public static final String CFG_GR_LOCAL = "GRL";
    public static final String CFG_GR_GLOBAL = "GRG";
    public static final String ACTION_INPUT_PARAM = "IN";
    public static final String ACTION_OUTPUT_PARAM = "OUT";
    public static final String CURRENT_DEPLOY = "CURRENT_DEPLOY";
    public static final String REMOTE_DEPLOY = "REMOTE_DEPLOY";

    // GR local configuration items
    public static final String CFG_GRL_DEPLOY_NAME = "DEPLOY_NAME";
    public static final String CFG_GRL_eIUM_USER = "EIUM_USER";
    public static final String CFG_GRL_eIUM_PWD = "EIUM_PWD";
    public static final String CFG_GRL_eIUM_HOME = "EIUM_HOME";
    public static final String CFG_SNAP_ENTERPRISE_OID = "SNAP_ENTERPRISE_OID";
    public static final String CFG_TRAP_MESSAGE_OID = "TRAP_MESSAGE_OID";
    public static final String CFG_GRL_ACTION_TIMEOUT = "ACTION_TIMEOUT";
    public static final String CFG_GRL_REST_REQUEST_TIMEOUT = "REST_REQUEST_TIMEOUT";
    public static final String CFG_GRL_VOLT_DB_START_TIMEOUT = "VOLT_DB_OPERATION_TIMEOUT";
    public static final String CFG_GRL_SS_CONFIG_EXPORT_TW = "SS_CONFIG_EXPORT_TW";
    public static final String CFG_GRL_ASYNC_ACTION_PLAN_THREAD_SIZE = "ASYNC_ACTION_PLAN_THREAD_SIZE";

    // REST Methods
    public static final String HTTP_METHOD_GET = "GET";
    public static final String HTTP_METHOD_PUT = "PUT";
    public static final String HTTP_METHOD_POST = "POST";
    public static final String HTTP_METHOD_DELETE = "DELETE";
    public static final String CFG_GRG_ROOT = "/SNAP/GR";
    public static final String CFG_GRG_SESSION_SERVER = CFG_GRG_ROOT + "/SESSION_SERVER";
    public static final String CFG_GRG_MASTER_SLAVE_RELATION = "MASTER_SLAVE";
    public static final String CFG_GRG_SNMP_ALARM_RECEIVERS = "SNMP_ALARM_RECEIVERS";
    public static final String CFG_GRG_AUTO_SWITCH_OVER = "AUTO_SWITCH_OVER";
    public static final String CFG_GRG_SGR_DATA_ROOT = "SGR_DATA_ROOT";
    public static final String CFG_GRG_SESSION_SERVER_TYPES = "SS_TYPES";
    public static final String CFG_GRG_SESSION_SERVER_STATUS_CANDIDATES = "SS_STATUS_CANDIDATES";
    public static final int RESTFUL_SUCCESS_STATUS_CODE = 200;
    public static final int RESTFUL_PUT_ASYNC_SUCCESS_STATUS_CODE = 202;
    public static final String CFG_GRG_SESSION_SERVER_START_SEQUENCE = "SS_START_SEQUENCE";
    public static final String VDB_STATUS_ONLINE = "ONLINE";
    public static final String VDB_STATUS_OFFLINE = "OFFLINE";
    public static final String VDB_STATUS_PAUSED = "PAUSED";
    public static final String VDB_MODE_REPLICA = "REPLICA";
    public static final String VDB_MODE_MASTER = "MASTER";
    public static final String CFG_GRG_SITE_GR_HOST = "GR_HOST";
    public static final String CFG_GRG_SITE_SSH_USER = "SSH_USER";
    public static final String CFG_GRG_HOST = "HOST";
    public static final String CFG_GRG_HOST_IP = "HOST_IP";
    public static final String CFG_GRG_HOST_FILES = "FILES";
    public static final String CFG_GRG_HOST_NAME = "HOST_NAME";
    public static final String CFG_GRG_HOST_SSH_USER = "SSH_USER";
    public static final String CFG_GRG_MYSQL = "MYSQL";
    public static final String CFG_GRG_MYSQL_DB_INST_NAME = "DB_INST_NAME";
    public static final String CFG_GRG_MYSQL_DB_HOST = "DB_HOST";
    public static final String CFG_GRG_MYSQL_DB_PORT = "DB_PORT";
    public static final String CFG_GRG_MYSQL_DB_USER = "DB_USER";
    public static final String CFG_GRG_MYSQL_DB_PWD = "DB_PWD";
    public static final String CFG_GRG_MYSQL_TABLE_LIST = "TABLE_LIST";
    public static final String CFG_GRG_VOLTDB = "VOLTDB";
    public static final String CFG_GRG_VEM_HOST = "VEM_HOST";
    public static final String CFG_GRG_VEM_PORT = "VEM_HTTP_PORT";
    public static final String CFG_GRG_VEM_URI = "VEM_REST_ROOT";
    public static final String CFG_GRG_VDB_REST_ROOT = "VDB_REST_ROOT";
    public static final String CFG_GRG_VOLTDB_DB_HTTP_PORT = "DB_HTTP_PORT";
    public static final String CFG_GRG_VOLTDB_DB_USER = "DB_USER";
    public static final String CFG_GRG_VOLTDB_DB_PWD = "DB_PWD";

    public static final String CFG_RTC_KERNEL_CONFIG = "/SNAP/RTC/Common/KernelConfig";
    public static final String CFG_RTC_BIZ_SERVICE_STATUS = "bizServiceStatus";

    //STATUS
    public static final String STATUS_REMOTE_SGM = "REMOTE_SGM_STATUS";
    public static final String STATUS_LOCAL_SGM = "LOCAL_SGM_STATUS";
    public static final String STATUS_LOCAL_ROLE = "Local_Role";
    public static final String STATUS_REMOTE_ROLE = "Remote_Role";
    public static final String STATUS_LOCAL_DEPLOYMENT_NAME = "Local_Deployment_Name";
    public static final String STATUS_REMOTE_DEPLOYMENT_NAME = "REMOTE_Deployment_Name";
    public static final String STATUS_SESSION_SERVER = "SessionServerStatus";
    public static final String STATUS_LOCAL_MONITOR = "Local_monitorSS";
    public static final String STATUS_REMOTE_MONITOR = "Remote_monitorSS";

    public static final String STATUS_CRON_JOB_ENABLE = "enable";
    public static final String STATUS_CRON_JOB_DISABLE = "disable";

    public static final String REMOTE_DEPLOY_STATUS = "REMOTE_DEPLOY_STATUS";
    public static final String DEPLOY_NODE_STATUS = "DEPLOY_NODE_STATUS";
    public static final String SESSION_SERVER_RESPONSE_TEXT = "SESSION_SERVERS";
    public static final String SESSION_SERVER_RESPONSE_HOST = "SESSION_SERVERS_HOST";
    public static final String SESSION_SERVER_RESPONSE_TEXT_CATEGORY = "SESSION_SERVERS_CATEGORY";

    public static final String ROLE_MASTER = "master";
    public static final String ROLE_SLAVE = "slave";

    //STORED PROCEDURE COMMAND
    public static final String STORED_PROCEDURE_PAUSE = "@Pause";
    public static final String STORED_PROCEDURE_RESUME = "@Resume";
    public static final String STORED_PROCEDURE_PROMOTE = "@Promote";
    public static final String STORED_PROCEDURE_SHUTDOWN = "@Shutdown";
    public static final String STORED_PROCEDURE_STATISTIC = "@Statistics";
    public static final String STORED_PROCEDURE_SYSTEMINFORMATION = "@SystemInformation";

    //Replica status
    public static final String REPLICA_STATUS_OFF = "NONE";
    public static final String REPLICA_STATUS_ON = "REPLICA";
    public static final String SSH_KEY_FILE = "id_rsa";
    public static final String VOLTDB_SP_URI_PREFIX = "/api/1.0/";
    public static final String LOCAL_SHELL_STDOUT = "__local_stdout";
    public static final String LOCAL_SHELL_STDERR = "__local_stderr";
    public static final String REMOTE_SHELL_STDOUT = "__remote_stdout";
    public static final String REMOTE_SHELL_STDERR = "__remote_stderr";
    public static final String SS_TYPE_STUDIO = "STUDIO";
    public static final String DEFAULT_ACTION_TIMEOUT = "660";
    public static final String DEFAULT_SS_CONFIG_EXPORT_TW = "1800";
    public static final String DB_STATUS_INFO_LOCAL = "LocalDBStatusInfo";
    public static final String DB_STATUS_INFO_REMOTE = "RemoteDBStatusInfo";
    public static final byte[] CRLF = new byte[]{'\n'};

    //JMX
    public static final String JMX_SNAP_OBJECT = "ATOM:type=Server,name=BizServiceManager";
    public static final String JMX_SET_BIZ_STATUS = "setAllBizState";
    public static final String JMX_GET_BIZ_STATUS = "currentBizServiceStatus";
    public static final String SNAP_JMX_PREFIX = "ManagementServiceInterface=";

    public static final Logger CONSOLE = LoggerFactory.getLogger("com.hp.snap.gr.Console");

    //DR Agent status
    public static final String DR_AGENT_NOT_AVAILABLE = "DR agent query is not available due to the failure of calling stored procedure.";

    public static final String REPLICATOR_STATUS_INFO = "_REPLICATOR_STATUS_INFO";
    public static final String REPLICATOR_REMOTE_STATUS_INFO = "_REPLICATOR_REMOTE_STATUS_INFO";
    
    public static final String KERNEL_CONFIG_RUNNING = "Running";

    public static final String GET_SESSIONSERVER_CONFIG = "CONFIG";
    public static final String GET_SESSIONSERVER_CONFIG_USER = "user";
    public static final String GET_SESSIONSERVER_CONFIG_PASSWORD = "password";
    public static final String GET_SESSIONSERVER_CONFIG_URL1 = "url1";
    public static final String GET_SESSIONSERVER_CONFIG_URL2 = "url2";
    public static final String GET_SESSIONSERVER_CONFIG_FILENANME = "fileName";
    public static final String GET_SESSIONSERVER_CONFIG_TASKID = "taskId";
    public static final String GET_SESSIONSERVER_CONFIG_PARAM = "param";

}


